import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ButtonVO, ButtonForm, ButtonQuery } from '@/api/sheet/button/types';

/**
 * 查询控件维护列表
 * @param query
 * @returns {*}
 */

export const listButton = (query?: ButtonQuery): AxiosPromise<ButtonVO[]> => {
  return request({
    url: '/system/button/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取所有控件
 * @param query
 */
export const listAllButton = (query?: ButtonQuery): AxiosPromise<ButtonVO[]> => {
  return request({
    url: '/system/button/listAll',
    method: 'get',
    params: query
  });
};

/**
 * 查询控件维护详细
 * @param buttonId
 */
export const getButton = (buttonId: string | number): AxiosPromise<ButtonVO> => {
  return request({
    url: '/system/button/' + buttonId,
    method: 'get'
  });
};

/**
 * 新增控件维护
 * @param data
 */
export const addButton = (data: ButtonForm) => {
  return request({
    url: '/system/button',
    method: 'post',
    data: data
  });
};

/**
 * 修改控件维护
 * @param data
 */
export const updateButton = (data: ButtonForm) => {
  return request({
    url: '/system/button',
    method: 'put',
    data: data
  });
};

/**
 * 删除控件维护
 * @param buttonId
 */
export const delButton = (buttonId: string | number | Array<string | number>) => {
  return request({
    url: '/system/button/' + buttonId,
    method: 'delete'
  });
};
